package cn.jhc.teachingquality.bean;

import java.io.Serializable;

/**
 * Created by luyanfei on 16-3-9.
 */
public class PracticeLog implements Comparable, Serializable{

    private long id;
    private String title;
    private String student;
    private int weekSeq;
    //hidden checkbox value for every entry
    private String hiddenId;

    public PracticeLog(){}

    public PracticeLog(String title, String student, int weekSeq, String hiddenId) {
        this.title = title;
        this.student = student;
        this.weekSeq = weekSeq;
        this.hiddenId = hiddenId;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getHiddenId() {
        return hiddenId;
    }

    public void setHiddenId(String hiddenId) {
        this.hiddenId = hiddenId;
    }

    public String getStudent() {
        return student;
    }

    public void setStudent(String student) {
        this.student = student;
    }

    public int getWeekSeq() {
        return weekSeq;
    }

    public void setWeekSeq(int weekSeq) {
        this.weekSeq = weekSeq;
    }

    public String getSubtitle() {
        return getStudent() + " （第" + getWeekSeq() + "周）";
    }

    @Override
    public int compareTo(Object another) {
        PracticeLog other = (PracticeLog)another;
        int weekDiff = other.getWeekSeq() - this.getWeekSeq();
        if(weekDiff != 0){
            return weekDiff;
        }
        else {
            return other.getHiddenId().compareTo(this.getHiddenId());
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        PracticeLog that = (PracticeLog) o;

        if (getWeekSeq() != that.getWeekSeq()) return false;
        return getHiddenId().equals(that.getHiddenId());

    }

    @Override
    public int hashCode() {
        int result = getWeekSeq();
        result = 31 * result + getHiddenId().hashCode();
        return result;
    }

    @Override
    public String toString() {
        return this.getTitle() + ":" + this.getStudent();
    }
}
